package com.demo.controller;

import com.demo.entity.User;
import com.demo.enums.Role;
import com.demo.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author gy
 * @date 2022/6/15
 */
@RestController
public class UserController {

    /**
     * 当前角色
     * */
    public static Role role= Role.VISITOR;

    @Autowired
    private final IUserService iUserService = null;

    @RequestMapping("/addUser")
    public void test(){
        iUserService.addUser();
        int i = 1/0;
    }

    @RequestMapping("/useTime")
    public void testUseTime(){
        iUserService.testUseTime();
    }

    @RequestMapping("/delUser")
    public void delUser(){
        iUserService.delUser();
    }

    @RequestMapping("/trans")
    public void transactionTest(){
        iUserService.addUser2(new User(3,"小明",20));
        iUserService.addUser2(new User(4,"小红",18));
    }
}
